package com.infinitus.autocatlog;



import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;
import com.infinitus.autocatlog.domain.KafkaConfig;
import com.infinitus.autocatlog.service.IpService;
import com.infinitus.autocatlog.service.RequestUtils;



@RestController
@EnableAutoConfiguration
@EnableScheduling
@ComponentScan(basePackages={"com.infinitus.autocatlog.*"})
public class App {
//	@Autowired
//    private RedisService redisService;
	
	@RequestMapping("/h")
//	@Cacheable(value = "function", keyGenerator = "keyGenerator")
	public String getSessionId(HttpSession session) {
//		redisService.set("123", "测试");
		System.out.println("进入了方法");
//		String string = redisService.get("123").toString();
		return "h";
	}
	
	@RequestMapping("/g")
	public String getCacheId(HttpSession session) {
		System.out.println("进入了方法");
//		String string = redisService.get("123").toString();
		return "g";
	}
	
	@RequestMapping("/uits/getIP")
	public Object getIp(HttpServletRequest req) {
		Map<String, Object> map = new HashMap<String, Object>();
		String ip = RequestUtils.getRemoteIp(req);
		String ipInfo = RequestUtils.recordUserIp(req);
		Map<String, String> findIpInfo = IpService.getInstance().findIpInfo(ip);
		map.put("ip", ip);
		map.put("ipInfo", ipInfo);
		map.put("findIpInfo", findIpInfo);
		return map;
	}
	
	
	public static void main(String[] args) {
		System.out.println("Hello World ! App!");
		SpringApplication.run(App.class, args);
		// SpringApplication.run(UserController.class, args);
	}
}
